/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.data.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author thiago
 */
@Entity
@Table(name = "estados")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Estados.findAll", query = "SELECT e FROM Estados e"),
    @NamedQuery(name = "Estados.findByCodigoest", query = "SELECT e FROM Estados e WHERE e.codigoest = :codigoest"),
    @NamedQuery(name = "Estados.findByNome", query = "SELECT e FROM Estados e WHERE e.nome = :nome")})
public class Estados implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "codigoest")
    private Integer codigoest;
    @Column(name = "nome")
    private String nome;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codigoest")
    private Collection<Clientes> clientesCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codigoest")
    private Collection<Fornecedores> fornecedoresCollection;

    public Estados() {
    }

    public Estados(Integer codigoest) {
        this.codigoest = codigoest;
    }

    public Integer getCodigoest() {
        return codigoest;
    }

    public void setCodigoest(Integer codigoest) {
        this.codigoest = codigoest;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    @XmlTransient
    public Collection<Clientes> getClientesCollection() {
        return clientesCollection;
    }

    public void setClientesCollection(Collection<Clientes> clientesCollection) {
        this.clientesCollection = clientesCollection;
    }

    @XmlTransient
    public Collection<Fornecedores> getFornecedoresCollection() {
        return fornecedoresCollection;
    }

    public void setFornecedoresCollection(Collection<Fornecedores> fornecedoresCollection) {
        this.fornecedoresCollection = fornecedoresCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codigoest != null ? codigoest.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Estados)) {
            return false;
        }
        Estados other = (Estados) object;
        if ((this.codigoest == null && other.codigoest != null) || (this.codigoest != null && !this.codigoest.equals(other.codigoest))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.data.model.Estados[ codigoest=" + codigoest + " ]";
    }
    
}
